#include "CXmlDesParser.h"

CXmlDesParser::CXmlDesParser()
{
}

CXmlDesParser::~CXmlDesParser()
{
	delete iParser;
	iParser = NULL;
	
}

CXmlDesParser* CXmlDesParser::NewL(MContentHandler& aContentHandler)
{
	CXmlDesParser* self = CXmlDesParser::NewLC(aContentHandler);
	CleanupStack::Pop(self);
	return self;
}

CXmlDesParser* CXmlDesParser::NewLC(MContentHandler& aContentHandler)
{
	CXmlDesParser* self = new(ELeave) CXmlDesParser;
	CleanupStack::PushL(self);
	self->ConstructL(aContentHandler);
	
	return self;
}

void CXmlDesParser::ConstructL(MContentHandler& aContentHandler)
{
	_LIT8(KMimeType,"text/xml");
	iParser = CParser::NewL(KMimeType,aContentHandler);
}

void CXmlDesParser::ParseXmlL(const TDesC& aDes)
{
	HBufC8* aBuf = HBufC8::NewL(aDes.Length());
	CleanupStack::PushL(aBuf);
	TPtr8 aPtr = aBuf->Des();
	aPtr.Copy(aDes);
	
	iParser->ParseBeginL();
	iParser->ParseL(aPtr);
	iParser->ParseEndL();
	
	CleanupStack::PopAndDestroy(aBuf);
}